home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / dev / gcc / ppc-mos-gcc.lha / info / gcc.info-13 (.txt) < prev    next >
GNU Info File  |  2002-06-18  |  50KB  |  869 lines

  1. This is Info file gcc.info, produced by Makeinfo version 1.68 from the
  2. input file ./gcc.texi.
  3. INFO-DIR-SECTION Programming
  4. START-INFO-DIR-ENTRY
  5. * gcc: (gcc).                  The GNU Compiler Collection.
  6. END-INFO-DIR-ENTRY
  7.    This file documents the use and the internals of the GNU compiler.
  8.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  9. Boston, MA 02111-1307 USA
  10.    Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
  11. 1999, 2000 Free Software Foundation, Inc.
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.    Permission is granted to copy and distribute modified versions of
  16. this manual under the conditions for verbatim copying, provided also
  17. that the sections entitled "GNU General Public License" and "Funding
  18. for Free Software" are included exactly as in the original, and
  19. provided that the entire resulting derived work is distributed under
  20. the terms of a permission notice identical to this one.
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions, except that the sections entitled "GNU General Public
  24. License" and "Funding for Free Software", and this permission notice,
  25. may be included in translations approved by the Free Software Foundation
  26. instead of in the original English.
  27. File: gcc.info,  Node: Installation Problems,  Next: Cross-Compiler Problems,  Prev: Actual Bugs,  Up: Trouble
  28. Installation Problems
  29. =====================
  30.    This is a list of problems (and some apparent problems which don't
  31. really mean anything is wrong) that show up during installation of GNU
  32.    * On certain systems, defining certain environment variables such as
  33.      `CC' can interfere with the functioning of `make'.
  34.    * If you encounter seemingly strange errors when trying to build the
  35.      compiler in a directory other than the source directory, it could
  36.      be because you have previously configured the compiler in the
  37.      source directory.  Make sure you have done all the necessary
  38.      preparations.  *Note Other Dir::.
  39.    * If you build GCC on a BSD system using a directory stored in a
  40.      System V file system, problems may occur in running `fixincludes'
  41.      if the System V file system doesn't support symbolic links.  These
  42.      problems result in a failure to fix the declaration of `size_t' in
  43.      `sys/types.h'.  If you find that `size_t' is a signed type and
  44.      that type mismatches occur, this could be the cause.
  45.      The solution is not to use such a directory for building GCC.
  46.    * In previous versions of GCC, the `gcc' driver program looked for
  47.      `as' and `ld' in various places; for example, in files beginning
  48.      with `/usr/local/lib/gcc-'.  GCC version 2 looks for them in the
  49.      directory `/usr/local/lib/gcc-lib/TARGET/VERSION'.
  50.      Thus, to use a version of `as' or `ld' that is not the system
  51.      default, for example `gas' or GNU `ld', you must put them in that
  52.      directory (or make links to them from that directory).
  53.    * Some commands executed when making the compiler may fail (return a
  54.      non-zero status) and be ignored by `make'.  These failures, which
  55.      are often due to files that were not found, are expected, and can
  56.      safely be ignored.
  57.    * It is normal to have warnings in compiling certain files about
  58.      unreachable code and about enumeration type clashes.  These files'
  59.      names begin with `insn-'.  Also, `real.c' may get some warnings
  60.      that you can ignore.
  61.    * Sometimes `make' recompiles parts of the compiler when installing
  62.      the compiler.  In one case, this was traced down to a bug in
  63.      `make'.  Either ignore the problem or switch to GNU Make.
  64.    * If you have installed a program known as purify, you may find that
  65.      it causes errors while linking `enquire', which is part of building
  66.      GCC.  The fix is to get rid of the file `real-ld' which purify
  67.      installs--so that GCC won't try to use it.
  68.    * On GNU/Linux SLS 1.01, there is a problem with `libc.a': it does
  69.      not contain the obstack functions.  However, GCC assumes that the
  70.      obstack functions are in `libc.a' when it is the GNU C library.
  71.      To work around this problem, change the `__GNU_LIBRARY__'
  72.      conditional around line 31 to `#if 1'.
  73.    * On some 386 systems, building the compiler never finishes because
  74.      `enquire' hangs due to a hardware problem in the motherboard--it
  75.      reports floating point exceptions to the kernel incorrectly.  You
  76.      can install GCC except for `float.h' by patching out the command to
  77.      run `enquire'.  You may also be able to fix the problem for real by
  78.      getting a replacement motherboard.  This problem was observed in
  79.      Revision E of the Micronics motherboard, and is fixed in Revision
  80.      F.  It has also been observed in the MYLEX MXA-33 motherboard.
  81.      If you encounter this problem, you may also want to consider
  82.      removing the FPU from the socket during the compilation.
  83.      Alternatively, if you are running SCO Unix, you can reboot and
  84.      force the FPU to be ignored.  To do this, type `hd(40)unix auto
  85.      ignorefpu'.
  86.    * On some 386 systems, GCC crashes trying to compile `enquire.c'.
  87.      This happens on machines that don't have a 387 FPU chip.  On 386
  88.      machines, the system kernel is supposed to emulate the 387 when you
  89.      don't have one.  The crash is due to a bug in the emulator.
  90.      One of these systems is the Unix from Interactive Systems: 386/ix.
  91.      On this system, an alternate emulator is provided, and it does
  92.      work.  To use it, execute this command as super-user:
  93.           ln /etc/emulator.rel1 /etc/emulator
  94.      and then reboot the system.  (The default emulator file remains
  95.      present under the name `emulator.dflt'.)
  96.      Try using `/etc/emulator.att', if you have such a problem on the
  97.      SCO system.
  98.      Another system which has this problem is Esix.  We don't know
  99.      whether it has an alternate emulator that works.
  100.      On NetBSD 0.8, a similar problem manifests itself as these error
  101.      messages:
  102.           enquire.c: In function `fprop':
  103.           enquire.c:2328: floating overflow
  104.    * On SCO systems, when compiling GCC with the system's compiler, do
  105.      not use `-O'.  Some versions of the system's compiler miscompile
  106.      GCC with `-O'.
  107.    * Sometimes on a Sun 4 you may observe a crash in the program
  108.      `genflags' or `genoutput' while building GCC.  This is said to be
  109.      due to a bug in `sh'.  You can probably get around it by running
  110.      `genflags' or `genoutput' manually and then retrying the `make'.
  111.    * On Solaris 2, executables of GCC version 2.0.2 are commonly
  112.      available, but they have a bug that shows up when compiling current
  113.      versions of GCC: undefined symbol errors occur during assembly if
  114.      you use `-g'.
  115.      The solution is to compile the current version of GCC without
  116.      `-g'.  That makes a working compiler which you can use to recompile
  117.      with `-g'.
  118.    * Solaris 2 comes with a number of optional OS packages.  Some of
  119.      these packages are needed to use GCC fully.  If you did not
  120.      install all optional packages when installing Solaris, you will
  121.      need to verify that the packages that GCC needs are installed.
  122.      To check whether an optional package is installed, use the
  123.      `pkginfo' command.  To add an optional package, use the `pkgadd'
  124.      command.  For further details, see the Solaris documentation.
  125.      For Solaris 2.0 and 2.1, GCC needs six packages: `SUNWarc',
  126.      `SUNWbtool', `SUNWesu', `SUNWhea', `SUNWlibm', and `SUNWtoo'.
  127.      For Solaris 2.2, GCC needs an additional seventh package:
  128.      `SUNWsprot'.
  129.    * On Solaris 2, trying to use the linker and other tools in
  130.      `/usr/ucb' to install GCC has been observed to cause trouble.  For
  131.      example, the linker may hang indefinitely.  The fix is to remove
  132.      `/usr/ucb' from your `PATH'.
  133.    * If you use the 1.31 version of the MIPS assembler (such as was
  134.      shipped with Ultrix 3.1), you will need to use the
  135.      -fno-delayed-branch switch when optimizing floating point code.
  136.      Otherwise, the assembler will complain when the GCC compiler fills
  137.      a branch delay slot with a floating point instruction, such as
  138.      `add.d'.
  139.    * If on a MIPS system you get an error message saying "does not have
  140.      gp sections for all it's [sic] sectons [sic]", don't worry about
  141.      it.  This happens whenever you use GAS with the MIPS linker, but
  142.      there is not really anything wrong, and it is okay to use the
  143.      output file.  You can stop such warnings by installing the GNU
  144.      linker.
  145.      It would be nice to extend GAS to produce the gp tables, but they
  146.      are optional, and there should not be a warning about their
  147.      absence.
  148.    * In Ultrix 4.0 on the MIPS machine, `stdio.h' does not work with GNU
  149.      CC at all unless it has been fixed with `fixincludes'.  This causes
  150.      problems in building GCC.  Once GCC is installed, the problems go
  151.      away.
  152.      To work around this problem, when making the stage 1 compiler,
  153.      specify this option to Make:
  154.           GCC_FOR_TARGET="./xgcc -B./ -I./include"
  155.      When making stage 2 and stage 3, specify this option:
  156.           CFLAGS="-g -I./include"
  157.    * Users have reported some problems with version 2.0 of the MIPS
  158.      compiler tools that were shipped with Ultrix 4.1.  Version 2.10
  159.      which came with Ultrix 4.2 seems to work fine.
  160.      Users have also reported some problems with version 2.20 of the
  161.      MIPS compiler tools that were shipped with RISC/os 4.x.  The
  162.      earlier version 2.11 seems to work fine.
  163.    * Some versions of the MIPS linker will issue an assertion failure
  164.      when linking code that uses `alloca' against shared libraries on
  165.      RISC-OS 5.0, and DEC's OSF/1 systems.  This is a bug in the
  166.      linker, that is supposed to be fixed in future revisions.  To
  167.      protect against this, GCC passes `-non_shared' to the linker
  168.      unless you pass an explicit `-shared' or `-call_shared' switch.
  169.    * On System V release 3, you may get this error message while
  170.      linking:
  171.           ld fatal: failed to write symbol name SOMETHING
  172.            in strings table for file WHATEVER
  173.      This probably indicates that the disk is full or your ULIMIT won't
  174.      allow the file to be as large as it needs to be.
  175.      This problem can also result because the kernel parameter `MAXUMEM'
  176.      is too small.  If so, you must regenerate the kernel and make the
  177.      value much larger.  The default value is reported to be 1024; a
  178.      value of 32768 is said to work.  Smaller values may also work.
  179.    * On System V, if you get an error like this,
  180.           /usr/local/lib/bison.simple: In function `yyparse':
  181.           /usr/local/lib/bison.simple:625: virtual memory exhausted
  182.      that too indicates a problem with disk space, ULIMIT, or `MAXUMEM'.
  183.    * Current GCC versions probably do not work on version 2 of the NeXT
  184.      operating system.
  185.    * On NeXTStep 3.0, the Objective C compiler does not work, due,
  186.      apparently, to a kernel bug that it happens to trigger.  This
  187.      problem does not happen on 3.1.
  188.    * On the Tower models 4N0 and 6N0, by default a process is not
  189.      allowed to have more than one megabyte of memory.  GCC cannot
  190.      compile itself (or many other programs) with `-O' in that much
  191.      memory.
  192.      To solve this problem, reconfigure the kernel adding the following
  193.      line to the configuration file:
  194.           MAXUMEM = 4096
  195.    * On HP 9000 series 300 or 400 running HP-UX release 8.0, there is a
  196.      bug in the assembler that must be fixed before GCC can be built.
  197.      This bug manifests itself during the first stage of compilation,
  198.      while building `libgcc2.a':
  199.           _floatdisf
  200.           cc1: warning: `-g' option not supported on this version of GCC
  201.           cc1: warning: `-g1' option not supported on this version of GCC
  202.           ./xgcc: Internal compiler error: program as got fatal signal 11
  203.      A patched version of the assembler is available by anonymous ftp
  204.      from `altdorf.ai.mit.edu' as the file
  205.      `archive/cph/hpux-8.0-assembler'.  If you have HP software support,
  206.      the patch can also be obtained directly from HP, as described in
  207.      the following note:
  208.           This is the patched assembler, to patch SR#1653-010439, where
  209.           the assembler aborts on floating point constants.
  210.           The bug is not really in the assembler, but in the shared
  211.           library version of the function "cvtnum(3c)".  The bug on
  212.           "cvtnum(3c)" is SR#4701-078451.  Anyway, the attached
  213.           assembler uses the archive library version of "cvtnum(3c)"
  214.           and thus does not exhibit the bug.
  215.      This patch is also known as PHCO_4484.
  216.    * On HP-UX version 8.05, but not on 8.07 or more recent versions,
  217.      the `fixproto' shell script triggers a bug in the system shell.
  218.      If you encounter this problem, upgrade your operating system or
  219.      use BASH (the GNU shell) to run `fixproto'.
  220.    * Some versions of the Pyramid C compiler are reported to be unable
  221.      to compile GCC.  You must use an older version of GCC for
  222.      bootstrapping.  One indication of this problem is if you get a
  223.      crash when GCC compiles the function `muldi3' in file `libgcc2.c'.
  224.      You may be able to succeed by getting GCC version 1, installing it,
  225.      and using it to compile GCC version 2.  The bug in the Pyramid C
  226.      compiler does not seem to affect GCC version 1.
  227.    * There may be similar problems on System V Release 3.1 on 386
  228.      systems.
  229.    * On the Intel Paragon (an i860 machine), if you are using operating
  230.      system version 1.0, you will get warnings or errors about
  231.      redefinition of `va_arg' when you build GCC.
  232.      If this happens, then you need to link most programs with the
  233.      library `iclib.a'.  You must also modify `stdio.h' as follows:
  234.      before the lines
  235.           #if     defined(__i860__) && !defined(_VA_LIST)
  236.           #include <va_list.h>
  237.      insert the line
  238.           #if __PGC__
  239.      and after the lines
  240.           extern int  vprintf(const char *, va_list );
  241.           extern int  vsprintf(char *, const char *, va_list );
  242.           #endif
  243.      insert the line
  244.           #endif /* __PGC__ */
  245.      These problems don't exist in operating system version 1.1.
  246.    * On the Altos 3068, programs compiled with GCC won't work unless you
  247.      fix a kernel bug.  This happens using system versions V.2.2 1.0gT1
  248.      and V.2.2 1.0e and perhaps later versions as well.  See the file
  249.      `README.ALTOS'.
  250.    * You will get several sorts of compilation and linking errors on the
  251.      we32k if you don't follow the special instructions.  *Note
  252.      Configurations::.
  253.    * A bug in the HP-UX 8.05 (and earlier) shell will cause the fixproto
  254.      program to report an error of the form:
  255.           ./fixproto: sh internal 1K buffer overflow
  256.      To fix this, change the first line of the fixproto script to look
  257.      like:
  258.           #!/bin/ksh
  259. File: gcc.info,  Node: Cross-Compiler Problems,  Next: Interoperation,  Prev: Installation Problems,  Up: Trouble
  260. Cross-Compiler Problems
  261. =======================
  262.    You may run into problems with cross compilation on certain machines,
  263. for several reasons.
  264.    * Cross compilation can run into trouble for certain machines because
  265.      some target machines' assemblers require floating point numbers to
  266.      be written as *integer* constants in certain contexts.
  267.      The compiler writes these integer constants by examining the
  268.      floating point value as an integer and printing that integer,
  269.      because this is simple to write and independent of the details of
  270.      the floating point representation.  But this does not work if the
  271.      compiler is running on a different machine with an incompatible
  272.      floating point format, or even a different byte-ordering.
  273.      In addition, correct constant folding of floating point values
  274.      requires representing them in the target machine's format.  (The C
  275.      standard does not quite require this, but in practice it is the
  276.      only way to win.)
  277.      It is now possible to overcome these problems by defining macros
  278.      such as `REAL_VALUE_TYPE'.  But doing so is a substantial amount of
  279.      work for each target machine.  *Note Cross-compilation::.
  280.    * At present, the program `mips-tfile' which adds debug support to
  281.      object files on MIPS systems does not work in a cross compile
  282.      environment.
  283. File: gcc.info,  Node: Interoperation,  Next: External Bugs,  Prev: Cross-Compiler Problems,  Up: Trouble
  284. Interoperation
  285. ==============
  286.    This section lists various difficulties encountered in using GNU C or
  287. GNU C++ together with other compilers or with the assemblers, linkers,
  288. libraries and debuggers on certain systems.
  289.    * Objective C does not work on the RS/6000.
  290.    * GNU C++ does not do name mangling in the same way as other C++
  291.      compilers.  This means that object files compiled with one compiler
  292.      cannot be used with another.
  293.      This effect is intentional, to protect you from more subtle
  294.      problems.  Compilers differ as to many internal details of C++
  295.      implementation, including: how class instances are laid out, how
  296.      multiple inheritance is implemented, and how virtual function
  297.      calls are handled.  If the name encoding were made the same, your
  298.      programs would link against libraries provided from other
  299.      compilers--but the programs would then crash when run.
  300.      Incompatible libraries are then detected at link time, rather than
  301.      at run time.
  302.    * Older GDB versions sometimes fail to read the output of GCC version
  303.      2.  If you have trouble, get GDB version 4.4 or later.
  304.    * DBX rejects some files produced by GCC, though it accepts similar
  305.      constructs in output from PCC.  Until someone can supply a coherent
  306.      description of what is valid DBX input and what is not, there is
  307.      nothing I can do about these problems.  You are on your own.
  308.    * The GNU assembler (GAS) does not support PIC.  To generate PIC
  309.      code, you must use some other assembler, such as `/bin/as'.
  310.    * On some BSD systems, including some versions of Ultrix, use of
  311.      profiling causes static variable destructors (currently used only
  312.      in C++) not to be run.
  313.    * Use of `-I/usr/include' may cause trouble.
  314.      Many systems come with header files that won't work with GCC unless
  315.      corrected by `fixincludes'.  The corrected header files go in a new
  316.      directory; GCC searches this directory before `/usr/include'.  If
  317.      you use `-I/usr/include', this tells GCC to search `/usr/include'
  318.      earlier on, before the corrected headers.  The result is that you
  319.      get the uncorrected header files.
  320.      Instead, you should use these options (when compiling C programs):
  321.           -I/usr/local/lib/gcc-lib/TARGET/VERSION/include -I/usr/include
  322.      For C++ programs, GCC also uses a special directory that defines
  323.      C++ interfaces to standard C subroutines.  This directory is meant
  324.      to be searched *before* other standard include directories, so
  325.      that it takes precedence.  If you are compiling C++ programs and
  326.      specifying include directories explicitly, use this option first,
  327.      then the two options above:
  328.           -I/usr/local/lib/g++-include
  329.    * On some SGI systems, when you use `-lgl_s' as an option, it gets
  330.      translated magically to `-lgl_s -lX11_s -lc_s'.  Naturally, this
  331.      does not happen when you use GCC.  You must specify all three
  332.      options explicitly.
  333.    * On a Sparc, GCC aligns all values of type `double' on an 8-byte
  334.      boundary, and it expects every `double' to be so aligned.  The Sun
  335.      compiler usually gives `double' values 8-byte alignment, with one
  336.      exception: function arguments of type `double' may not be aligned.
  337.      As a result, if a function compiled with Sun CC takes the address
  338.      of an argument of type `double' and passes this pointer of type
  339.      `double *' to a function compiled with GCC, dereferencing the
  340.      pointer may cause a fatal signal.
  341.      One way to solve this problem is to compile your entire program
  342.      with GNU CC.  Another solution is to modify the function that is
  343.      compiled with Sun CC to copy the argument into a local variable;
  344.      local variables are always properly aligned.  A third solution is
  345.      to modify the function that uses the pointer to dereference it via
  346.      the following function `access_double' instead of directly with
  347.      `*':
  348.           inline double
  349.           access_double (double *unaligned_ptr)
  350.           {
  351.             union d2i { double d; int i[2]; };
  352.           
  353.             union d2i *p = (union d2i *) unaligned_ptr;
  354.             union d2i u;
  355.           
  356.             u.i[0] = p->i[0];
  357.             u.i[1] = p->i[1];
  358.           
  359.             return u.d;
  360.           }
  361.      Storing into the pointer can be done likewise with the same union.
  362.    * On Solaris, the `malloc' function in the `libmalloc.a' library may
  363.      allocate memory that is only 4 byte aligned.  Since GCC on the
  364.      Sparc assumes that doubles are 8 byte aligned, this may result in a
  365.      fatal signal if doubles are stored in memory allocated by the
  366.      `libmalloc.a' library.
  367.      The solution is to not use the `libmalloc.a' library.  Use instead
  368.      `malloc' and related functions from `libc.a'; they do not have
  369.      this problem.
  370.    * Sun forgot to include a static version of `libdl.a' with some
  371.      versions of SunOS (mainly 4.1).  This results in undefined symbols
  372.      when linking static binaries (that is, if you use `-static').  If
  373.      you see undefined symbols `_dlclose', `_dlsym' or `_dlopen' when
  374.      linking, compile and link against the file `mit/util/misc/dlsym.c'
  375.      from the MIT version of X windows.
  376.    * The 128-bit long double format that the Sparc port supports
  377.      currently works by using the architecturally defined quad-word
  378.      floating point instructions.  Since there is no hardware that
  379.      supports these instructions they must be emulated by the operating
  380.      system.  Long doubles do not work in Sun OS versions 4.0.3 and
  381.      earlier, because the kernel emulator uses an obsolete and
  382.      incompatible format.  Long doubles do not work in Sun OS version
  383.      4.1.1 due to a problem in a Sun library.  Long doubles do work on
  384.      Sun OS versions 4.1.2 and higher, but GCC does not enable them by
  385.      default.  Long doubles appear to work in Sun OS 5.x (Solaris 2.x).
  386.    * On HP-UX version 9.01 on the HP PA, the HP compiler `cc' does not
  387.      compile GCC correctly.  We do not yet know why.  However, GCC
  388.      compiled on earlier HP-UX versions works properly on HP-UX 9.01
  389.      and can compile itself properly on 9.01.
  390.    * On the HP PA machine, ADB sometimes fails to work on functions
  391.      compiled with GCC.  Specifically, it fails to work on functions
  392.      that use `alloca' or variable-size arrays.  This is because GCC
  393.      doesn't generate HP-UX unwind descriptors for such functions.  It
  394.      may even be impossible to generate them.
  395.    * Debugging (`-g') is not supported on the HP PA machine, unless you
  396.      use the preliminary GNU tools (*note Installation::.).
  397.    * Taking the address of a label may generate errors from the HP-UX
  398.      PA assembler.  GAS for the PA does not have this problem.
  399.    * Using floating point parameters for indirect calls to static
  400.      functions will not work when using the HP assembler.  There simply
  401.      is no way for GCC to specify what registers hold arguments for
  402.      static functions when using the HP assembler.  GAS for the PA does
  403.      not have this problem.
  404.    * In extremely rare cases involving some very large functions you may
  405.      receive errors from the HP linker complaining about an out of
  406.      bounds unconditional branch offset.  This used to occur more often
  407.      in previous versions of GCC, but is now exceptionally rare.  If
  408.      you should run into it, you can work around by making your
  409.      function smaller.
  410.    * GCC compiled code sometimes emits warnings from the HP-UX
  411.      assembler of the form:
  412.           (warning) Use of GR3 when
  413.             frame >= 8192 may cause conflict.
  414.      These warnings are harmless and can be safely ignored.
  415.    * The current version of the assembler (`/bin/as') for the RS/6000
  416.      has certain problems that prevent the `-g' option in GCC from
  417.      working.  Note that `Makefile.in' uses `-g' by default when
  418.      compiling `libgcc2.c'.
  419.      IBM has produced a fixed version of the assembler.  The upgraded
  420.      assembler unfortunately was not included in any of the AIX 3.2
  421.      update PTF releases (3.2.2, 3.2.3, or 3.2.3e).  Users of AIX 3.1
  422.      should request PTF U403044 from IBM and users of AIX 3.2 should
  423.      request PTF U416277.  See the file `README.RS6000' for more
  424.      details on these updates.
  425.      You can test for the presense of a fixed assembler by using the
  426.      command
  427.           as -u < /dev/null
  428.      If the command exits normally, the assembler fix already is
  429.      installed.  If the assembler complains that "-u" is an unknown
  430.      flag, you need to order the fix.
  431.    * On the IBM RS/6000, compiling code of the form
  432.           extern int foo;
  433.           
  434.           ... foo ...
  435.           
  436.           static int foo;
  437.      will cause the linker to report an undefined symbol `foo'.
  438.      Although this behavior differs from most other systems, it is not a
  439.      bug because redefining an `extern' variable as `static' is
  440.      undefined in ANSI C.
  441.    * AIX on the RS/6000 provides support (NLS) for environments outside
  442.      of the United States.  Compilers and assemblers use NLS to support
  443.      locale-specific representations of various objects including
  444.      floating-point numbers ("." vs "," for separating decimal
  445.      fractions).  There have been problems reported where the library
  446.      linked with GCC does not produce the same floating-point formats
  447.      that the assembler accepts.  If you have this problem, set the
  448.      LANG environment variable to "C" or "En_US".
  449.    * Even if you specify `-fdollars-in-identifiers', you cannot
  450.      successfully use `$' in identifiers on the RS/6000 due to a
  451.      restriction in the IBM assembler.  GAS supports these identifiers.
  452.    * On the RS/6000, XLC version 1.3.0.0 will miscompile `jump.c'.  XLC
  453.      version 1.3.0.1 or later fixes this problem.  You can obtain
  454.      XLC-1.3.0.2 by requesting PTF 421749 from IBM.
  455.    * There is an assembler bug in versions of DG/UX prior to 5.4.2.01
  456.      that occurs when the `fldcr' instruction is used.  GCC uses
  457.      `fldcr' on the 88100 to serialize volatile memory references.  Use
  458.      the option `-mno-serialize-volatile' if your version of the
  459.      assembler has this bug.
  460.    * On VMS, GAS versions 1.38.1 and earlier may cause spurious warning
  461.      messages from the linker.  These warning messages complain of
  462.      mismatched psect attributes.  You can ignore them.  *Note VMS
  463.      Install::.
  464.    * On NewsOS version 3, if you include both of the files `stddef.h'
  465.      and `sys/types.h', you get an error because there are two typedefs
  466.      of `size_t'.  You should change `sys/types.h' by adding these
  467.      lines around the definition of `size_t':
  468.           #ifndef _SIZE_T
  469.           #define _SIZE_T
  470.           ACTUAL TYPEDEF HERE
  471.           #endif
  472.    * On the Alliant, the system's own convention for returning
  473.      structures and unions is unusual, and is not compatible with GCC
  474.      no matter what options are used.
  475.    * On the IBM RT PC, the MetaWare HighC compiler (hc) uses a different
  476.      convention for structure and union returning.  Use the option
  477.      `-mhc-struct-return' to tell GCC to use a convention compatible
  478.      with it.
  479.    * On Ultrix, the Fortran compiler expects registers 2 through 5 to
  480.      be saved by function calls.  However, the C compiler uses
  481.      conventions compatible with BSD Unix: registers 2 through 5 may be
  482.      clobbered by function calls.
  483.      GCC uses the same convention as the Ultrix C compiler.  You can use
  484.      these options to produce code compatible with the Fortran compiler:
  485.           -fcall-saved-r2 -fcall-saved-r3 -fcall-saved-r4 -fcall-saved-r5
  486.    * On the WE32k, you may find that programs compiled with GCC do not
  487.      work with the standard shared C library.  You may need to link with
  488.      the ordinary C compiler.  If you do so, you must specify the
  489.      following options:
  490.           -L/usr/local/lib/gcc-lib/we32k-att-sysv/2.8.1 -lgcc -lc_s
  491.      The first specifies where to find the library `libgcc.a' specified
  492.      with the `-lgcc' option.
  493.      GCC does linking by invoking `ld', just as `cc' does, and there is
  494.      no reason why it *should* matter which compilation program you use
  495.      to invoke `ld'.  If someone tracks this problem down, it can
  496.      probably be fixed easily.
  497.    * On the Alpha, you may get assembler errors about invalid syntax as
  498.      a result of floating point constants.  This is due to a bug in the
  499.      C library functions `ecvt', `fcvt' and `gcvt'.  Given valid
  500.      floating point numbers, they sometimes print `NaN'.
  501.    * On Irix 4.0.5F (and perhaps in some other versions), an assembler
  502.      bug sometimes reorders instructions incorrectly when optimization
  503.      is turned on.  If you think this may be happening to you, try
  504.      using the GNU assembler; GAS version 2.1 supports ECOFF on Irix.
  505.      Or use the `-noasmopt' option when you compile GCC with itself,
  506.      and then again when you compile your program.  (This is a temporary
  507.      kludge to turn off assembler optimization on Irix.)  If this
  508.      proves to be what you need, edit the assembler spec in the file
  509.      `specs' so that it unconditionally passes `-O0' to the assembler,
  510.      and never passes `-O2' or `-O3'.
  511. File: gcc.info,  Node: External Bugs,  Next: Incompatibilities,  Prev: Interoperation,  Up: Trouble
  512. Problems Compiling Certain Programs
  513. ===================================
  514.    Certain programs have problems compiling.
  515.    * Parse errors may occur compiling X11 on a Decstation running
  516.      Ultrix 4.2 because of problems in DEC's versions of the X11 header
  517.      files `X11/Xlib.h' and `X11/Xutil.h'.  People recommend adding
  518.      `-I/usr/include/mit' to use the MIT versions of the header files,
  519.      using the `-traditional' switch to turn off ANSI C, or fixing the
  520.      header files by adding this:
  521.           #ifdef __STDC__
  522.           #define NeedFunctionPrototypes 0
  523.           #endif
  524.    * If you have trouble compiling Perl on a SunOS 4 system, it may be
  525.      because Perl specifies `-I/usr/ucbinclude'.  This accesses the
  526.      unfixed header files.  Perl specifies the options
  527.           -traditional -Dvolatile=__volatile__
  528.           -I/usr/include/sun -I/usr/ucbinclude
  529.           -fpcc-struct-return
  530.      most of which are unnecessary with GCC 2.4.5 and newer versions.
  531.      You can make a properly working Perl by setting `ccflags' to
  532.      `-fwritable-strings' (implied by the `-traditional' in the
  533.      original options) and `cppflags' to empty in `config.sh', then
  534.      typing `./doSH; make depend; make'.
  535.    * On various 386 Unix systems derived from System V, including SCO,
  536.      ISC, and ESIX, you may get error messages about running out of
  537.      virtual memory while compiling certain programs.
  538.      You can prevent this problem by linking GCC with the GNU malloc
  539.      (which thus replaces the malloc that comes with the system).  GNU
  540.      malloc is available as a separate package, and also in the file
  541.      `src/gmalloc.c' in the GNU Emacs 19 distribution.
  542.      If you have installed GNU malloc as a separate library package,
  543.      use this option when you relink GCC:
  544.           MALLOC=/usr/local/lib/libgmalloc.a
  545.      Alternatively, if you have compiled `gmalloc.c' from Emacs 19, copy
  546.      the object file to `gmalloc.o' and use this option when you relink
  547.      GCC:
  548.           MALLOC=gmalloc.o
  549. File: gcc.info,  Node: Incompatibilities,  Next: Fixed Headers,  Prev: External Bugs,  Up: Trouble
  550. Incompatibilities of GCC
  551. ========================
  552.    There are several noteworthy incompatibilities between GNU C and most
  553. existing (non-ANSI) versions of C.  The `-traditional' option
  554. eliminates many of these incompatibilities, *but not all*, by telling
  555. GNU C to behave like the other C compilers.
  556.    * GCC normally makes string constants read-only.  If several
  557.      identical-looking string constants are used, GCC stores only one
  558.      copy of the string.
  559.      One consequence is that you cannot call `mktemp' with a string
  560.      constant argument.  The function `mktemp' always alters the string
  561.      its argument points to.
  562.      Another consequence is that `sscanf' does not work on some systems
  563.      when passed a string constant as its format control string or
  564.      input.  This is because `sscanf' incorrectly tries to write into
  565.      the string constant.  Likewise `fscanf' and `scanf'.
  566.      The best solution to these problems is to change the program to use
  567.      `char'-array variables with initialization strings for these
  568.      purposes instead of string constants.  But if this is not possible,
  569.      you can use the `-fwritable-strings' flag, which directs GCC to
  570.      handle string constants the same way most C compilers do.
  571.      `-traditional' also has this effect, among others.
  572.    * `-2147483648' is positive.
  573.      This is because 2147483648 cannot fit in the type `int', so
  574.      (following the ANSI C rules) its data type is `unsigned long int'.
  575.      Negating this value yields 2147483648 again.
  576.    * GCC does not substitute macro arguments when they appear inside of
  577.      string constants.  For example, the following macro in GCC
  578.           #define foo(a) "a"
  579.      will produce output `"a"' regardless of what the argument A is.
  580.      The `-traditional' option directs GCC to handle such cases (among
  581.      others) in the old-fashioned (non-ANSI) fashion.
  582.    * When you use `setjmp' and `longjmp', the only automatic variables
  583.      guaranteed to remain valid are those declared `volatile'.  This is
  584.      a consequence of automatic register allocation.  Consider this
  585.      function:
  586.           jmp_buf j;
  587.           
  588.           foo ()
  589.           {
  590.             int a, b;
  591.           
  592.             a = fun1 ();
  593.             if (setjmp (j))
  594.               return a;
  595.           
  596.             a = fun2 ();
  597.             /* `longjmp (j)' may occur in `fun3'. */
  598.             return a + fun3 ();
  599.           }
  600.      Here `a' may or may not be restored to its first value when the
  601.      `longjmp' occurs.  If `a' is allocated in a register, then its
  602.      first value is restored; otherwise, it keeps the last value stored
  603.      in it.
  604.      If you use the `-W' option with the `-O' option, you will get a
  605.      warning when GCC thinks such a problem might be possible.
  606.      The `-traditional' option directs GNU C to put variables in the
  607.      stack by default, rather than in registers, in functions that call
  608.      `setjmp'.  This results in the behavior found in traditional C
  609.      compilers.
  610.    * Programs that use preprocessing directives in the middle of macro
  611.      arguments do not work with GCC.  For example, a program like this
  612.      will not work:
  613.           foobar (
  614.           #define luser
  615.                   hack)
  616.      ANSI C does not permit such a construct.  It would make sense to
  617.      support it when `-traditional' is used, but it is too much work to
  618.      implement.
  619.    * Declarations of external variables and functions within a block
  620.      apply only to the block containing the declaration.  In other
  621.      words, they have the same scope as any other declaration in the
  622.      same place.
  623.      In some other C compilers, a `extern' declaration affects all the
  624.      rest of the file even if it happens within a block.
  625.      The `-traditional' option directs GNU C to treat all `extern'
  626.      declarations as global, like traditional compilers.
  627.    * In traditional C, you can combine `long', etc., with a typedef
  628.      name, as shown here:
  629.           typedef int foo;
  630.           typedef long foo bar;
  631.      In ANSI C, this is not allowed: `long' and other type modifiers
  632.      require an explicit `int'.  Because this criterion is expressed by
  633.      Bison grammar rules rather than C code, the `-traditional' flag
  634.      cannot alter it.
  635.    * PCC allows typedef names to be used as function parameters.  The
  636.      difficulty described immediately above applies here too.
  637.    * PCC allows whitespace in the middle of compound assignment
  638.      operators such as `+='.  GCC, following the ANSI standard, does not
  639.      allow this.  The difficulty described immediately above applies
  640.      here too.
  641.    * GCC complains about unterminated character constants inside of
  642.      preprocessing conditionals that fail.  Some programs have English
  643.      comments enclosed in conditionals that are guaranteed to fail; if
  644.      these comments contain apostrophes, GCC will probably report an
  645.      error.  For example, this code would produce an error:
  646.           #if 0
  647.           You can't expect this to work.
  648.           #endif
  649.      The best solution to such a problem is to put the text into an
  650.      actual C comment delimited by `/*...*/'.  However, `-traditional'
  651.      suppresses these error messages.
  652.    * Many user programs contain the declaration `long time ();'.  In the
  653.      past, the system header files on many systems did not actually
  654.      declare `time', so it did not matter what type your program
  655.      declared it to return.  But in systems with ANSI C headers, `time'
  656.      is declared to return `time_t', and if that is not the same as
  657.      `long', then `long time ();' is erroneous.
  658.      The solution is to change your program to use `time_t' as the
  659.      return type of `time'.
  660.    * When compiling functions that return `float', PCC converts it to a
  661.      double.  GCC actually returns a `float'.  If you are concerned
  662.      with PCC compatibility, you should declare your functions to return
  663.      `double'; you might as well say what you mean.
  664.    * When compiling functions that return structures or unions, GCC
  665.      output code normally uses a method different from that used on most
  666.      versions of Unix.  As a result, code compiled with GCC cannot call
  667.      a structure-returning function compiled with PCC, and vice versa.
  668.      The method used by GCC is as follows: a structure or union which is
  669.      1, 2, 4 or 8 bytes long is returned like a scalar.  A structure or
  670.      union with any other size is stored into an address supplied by
  671.      the caller (usually in a special, fixed register, but on some
  672.      machines it is passed on the stack).  The machine-description
  673.      macros `STRUCT_VALUE' and `STRUCT_INCOMING_VALUE' tell GCC where
  674.      to pass this address.
  675.      By contrast, PCC on most target machines returns structures and
  676.      unions of any size by copying the data into an area of static
  677.      storage, and then returning the address of that storage as if it
  678.      were a pointer value.  The caller must copy the data from that
  679.      memory area to the place where the value is wanted.  GCC does not
  680.      use this method because it is slower and nonreentrant.
  681.      On some newer machines, PCC uses a reentrant convention for all
  682.      structure and union returning.  GCC on most of these machines uses
  683.      a compatible convention when returning structures and unions in
  684.      memory, but still returns small structures and unions in registers.
  685.      You can tell GCC to use a compatible convention for all structure
  686.      and union returning with the option `-fpcc-struct-return'.
  687.    * GNU C complains about program fragments such as `0x74ae-0x4000'
  688.      which appear to be two hexadecimal constants separated by the minus
  689.      operator.  Actually, this string is a single "preprocessing token".
  690.      Each such token must correspond to one token in C.  Since this
  691.      does not, GNU C prints an error message.  Although it may appear
  692.      obvious that what is meant is an operator and two values, the ANSI
  693.      C standard specifically requires that this be treated as erroneous.
  694.      A "preprocessing token" is a "preprocessing number" if it begins
  695.      with a digit and is followed by letters, underscores, digits,
  696.      periods and `e+', `e-', `E+', or `E-' character sequences.
  697.      To make the above program fragment valid, place whitespace in
  698.      front of the minus sign.  This whitespace will end the
  699.      preprocessing number.
  700. File: gcc.info,  Node: Fixed Headers,  Next: Standard Libraries,  Prev: Incompatibilities,  Up: Trouble
  701. Fixed Header Files
  702. ==================
  703.    GCC needs to install corrected versions of some system header files.
  704. This is because most target systems have some header files that won't
  705. work with GCC unless they are changed.  Some have bugs, some are
  706. incompatible with ANSI C, and some depend on special features of other
  707. compilers.
  708.    Installing GCC automatically creates and installs the fixed header
  709. files, by running a program called `fixincludes' (or for certain
  710. targets an alternative such as `fixinc.svr4').  Normally, you don't
  711. need to pay attention to this.  But there are cases where it doesn't do
  712. the right thing automatically.
  713.    * If you update the system's header files, such as by installing a
  714.      new system version, the fixed header files of GCC are not
  715.      automatically updated.  The easiest way to update them is to
  716.      reinstall GCC.  (If you want to be clever, look in the makefile
  717.      and you can find a shortcut.)
  718.    * On some systems, in particular SunOS 4, header file directories
  719.      contain machine-specific symbolic links in certain places.  This
  720.      makes it possible to share most of the header files among hosts
  721.      running the same version of SunOS 4 on different machine models.
  722.      The programs that fix the header files do not understand this
  723.      special way of using symbolic links; therefore, the directory of
  724.      fixed header files is good only for the machine model used to
  725.      build it.
  726.      In SunOS 4, only programs that look inside the kernel will notice
  727.      the difference between machine models.  Therefore, for most
  728.      purposes, you need not be concerned about this.
  729.      It is possible to make separate sets of fixed header files for the
  730.      different machine models, and arrange a structure of symbolic
  731.      links so as to use the proper set, but you'll have to do this by
  732.      hand.
  733.    * On Lynxos, GCC by default does not fix the header files.  This is
  734.      because bugs in the shell cause the `fixincludes' script to fail.
  735.      This means you will encounter problems due to bugs in the system
  736.      header files.  It may be no comfort that they aren't GCC's fault,
  737.      but it does mean that there's nothing for us to do about them.
  738. File: gcc.info,  Node: Standard Libraries,  Next: Disappointments,  Prev: Fixed Headers,  Up: Trouble
  739. Standard Libraries
  740. ==================
  741.    GCC by itself attempts to be what the ISO/ANSI C standard calls a
  742. "conforming freestanding implementation".  This means all ANSI C
  743. language features are available, as well as the contents of `float.h',
  744. `limits.h', `stdarg.h', and `stddef.h'.  The rest of the C library is
  745. supplied by the vendor of the operating system.  If that C library
  746. doesn't conform to the C standards, then your programs might get
  747. warnings (especially when using `-Wall') that you don't expect.
  748.    For example, the `sprintf' function on SunOS 4.1.3 returns `char *'
  749. while the C standard says that `sprintf' returns an `int'.  The
  750. `fixincludes' program could make the prototype for this function match
  751. the Standard, but that would be wrong, since the function will still
  752. return `char *'.
  753.    If you need a Standard compliant library, then you need to find one,
  754. as GCC does not provide one.  The GNU C library (called `glibc') has
  755. been ported to a number of operating systems, and provides ANSI/ISO,
  756. POSIX, BSD and SystemV compatibility.  You could also ask your operating
  757. system vendor if newer libraries are available.
  758. File: gcc.info,  Node: Disappointments,  Next: C++ Misunderstandings,  Prev: Standard Libraries,  Up: Trouble
  759. Disappointments and Misunderstandings
  760. =====================================
  761.    These problems are perhaps regrettable, but we don't know any
  762. practical way around them.
  763.    * Certain local variables aren't recognized by debuggers when you
  764.      compile with optimization.
  765.      This occurs because sometimes GCC optimizes the variable out of
  766.      existence.  There is no way to tell the debugger how to compute the
  767.      value such a variable "would have had", and it is not clear that
  768.      would be desirable anyway.  So GCC simply does not mention the
  769.      eliminated variable when it writes debugging information.
  770.      You have to expect a certain amount of disagreement between the
  771.      executable and your source code, when you use optimization.
  772.    * Users often think it is a bug when GCC reports an error for code
  773.      like this:
  774.           int foo (struct mumble *);
  775.           
  776.           struct mumble { ... };
  777.           
  778.           int foo (struct mumble *x)
  779.           { ... }
  780.      This code really is erroneous, because the scope of `struct
  781.      mumble' in the prototype is limited to the argument list
  782.      containing it.  It does not refer to the `struct mumble' defined
  783.      with file scope immediately below--they are two unrelated types
  784.      with similar names in different scopes.
  785.      But in the definition of `foo', the file-scope type is used
  786.      because that is available to be inherited.  Thus, the definition
  787.      and the prototype do not match, and you get an error.
  788.      This behavior may seem silly, but it's what the ANSI standard
  789.      specifies.  It is easy enough for you to make your code work by
  790.      moving the definition of `struct mumble' above the prototype.
  791.      It's not worth being incompatible with ANSI C just to avoid an
  792.      error for the example shown above.
  793.    * Accesses to bitfields even in volatile objects works by accessing
  794.      larger objects, such as a byte or a word.  You cannot rely on what
  795.      size of object is accessed in order to read or write the bitfield;
  796.      it may even vary for a given bitfield according to the precise
  797.      usage.
  798.      If you care about controlling the amount of memory that is
  799.      accessed, use volatile but do not use bitfields.
  800.    * GCC comes with shell scripts to fix certain known problems in
  801.      system header files.  They install corrected copies of various
  802.      header files in a special directory where only GCC will normally
  803.      look for them.  The scripts adapt to various systems by searching
  804.      all the system header files for the problem cases that we know
  805.      about.
  806.      If new system header files are installed, nothing automatically
  807.      arranges to update the corrected header files.  You will have to
  808.      reinstall GCC to fix the new header files.  More specifically, go
  809.      to the build directory and delete the files `stmp-fixinc' and
  810.      `stmp-headers', and the subdirectory `include'; then do `make
  811.      install' again.
  812.    * On 68000 and x86 systems, for instance, you can get paradoxical
  813.      results if you test the precise values of floating point numbers.
  814.      For example, you can find that a floating point value which is not
  815.      a NaN is not equal to itself.  This results from the fact that the
  816.      floating point registers hold a few more bits of precision than
  817.      fit in a `double' in memory.  Compiled code moves values between
  818.      memory and floating point registers at its convenience, and moving
  819.      them into memory truncates them.
  820.      You can partially avoid this problem by using the `-ffloat-store'
  821.      option (*note Optimize Options::.).
  822.    * On the MIPS, variable argument functions using `varargs.h' cannot
  823.      have a floating point value for the first argument.  The reason
  824.      for this is that in the absence of a prototype in scope, if the
  825.      first argument is a floating point, it is passed in a floating
  826.      point register, rather than an integer register.
  827.      If the code is rewritten to use the ANSI standard `stdarg.h'
  828.      method of variable arguments, and the prototype is in scope at the
  829.      time of the call, everything will work fine.
  830.    * On the H8/300 and H8/300H, variable argument functions must be
  831.      implemented using the ANSI standard `stdarg.h' method of variable
  832.      arguments.  Furthermore, calls to functions using `stdarg.h'
  833.      variable arguments must have a prototype for the called function
  834.      in scope at the time of the call.
  835. File: gcc.info,  Node: C++ Misunderstandings,  Next: Protoize Caveats,  Prev: Disappointments,  Up: Trouble
  836. Common Misunderstandings with GNU C++
  837. =====================================
  838.    C++ is a complex language and an evolving one, and its standard
  839. definition (the ISO C++ standard) was only recently completed.  As a
  840. result, your C++ compiler may occasionally surprise you, even when its
  841. behavior is correct.  This section discusses some areas that frequently
  842. give rise to questions of this sort.
  843. * Menu:
  844. * Static Definitions::  Static member declarations are not definitions
  845. * Temporaries::         Temporaries may vanish before you expect
  846. * Copy Assignment::     Copy Assignment operators copy virtual bases twice
  847. File: gcc.info,  Node: Static Definitions,  Next: Temporaries,  Up: C++ Misunderstandings
  848. Declare *and* Define Static Members
  849. -----------------------------------
  850.    When a class has static data members, it is not enough to *declare*
  851. the static member; you must also *define* it.  For example:
  852.      class Foo
  853.      {
  854.        ...
  855.        void method();
  856.        static int bar;
  857.      };
  858.    This declaration only establishes that the class `Foo' has an `int'
  859. named `Foo::bar', and a member function named `Foo::method'.  But you
  860. still need to define *both* `method' and `bar' elsewhere.  According to
  861. the draft ANSI standard, you must supply an initializer in one (and
  862. only one) source file, such as:
  863.      int Foo::bar = 0;
  864.    Other C++ compilers may not correctly implement the standard
  865. behavior.  As a result, when you switch to `g++' from one of these
  866. compilers, you may discover that a program that appeared to work
  867. correctly in fact does not conform to the standard: `g++' reports as
  868. undefined symbols any static data members that lack definitions.
  869.